using DataAggregationService.Model;
using DataAggregationService.Service;
using Microsoft.Extensions.Options;

namespace DataAggregationService
{
	public class Program
	{
		public static void Main(string[] args)
		{
			IHost host = Host.CreateDefaultBuilder(args)
				.ConfigureAppConfiguration((hostingContext, config) =>
				{
					config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
				})
				.ConfigureServices((hostContext, services) =>
				{
					services.AddHostedService<Worker>();
					services.AddSingleton<IDbService, DbServiceImpl>();
					services.Configure<SyncConfig>(hostContext.Configuration.GetSection("SyncConfig"));
				})
				.UseWindowsService()
				.Build();

			host.Run();
		}
	}
}
